<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="a.header.jsp" %>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head> 
 <body>
 <form class="layui-form" action="">
  
  <div class="layui-form-item">
    <label class="layui-form-label">复选框</label>
    <div class="layui-input-block" id="t">
      <input type="checkbox" name="like[write]" title="写作">
      <input type="checkbox" name="like[read]" title="阅读" checked="">
      <input type="checkbox" name="like[game]" title="游戏">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
  </form>
          
<!-- a2获取复选框的值.jsp -->
<script>
//Demo
layui.use('form', function(){
  var form = layui.form,
  $=layui.$;
  layer.ready(function(){	   
	  var title='test';
	  var value='测试'
	  $('#t').append("<input type='checkbox' name="+title+" title="+value+">");
	  form.render();
	});   
  
  //监听提交
  form.on('submit(formDemo)', function(data){
    layer.msg(JSON.stringify(data.field));
    return false;
  });
});
</script>
</body>

</html>